package com.fdb.efp.nls.service.impl;

import com.alibaba.dubbo.rpc.service.GenericException;
import com.alibaba.dubbo.rpc.service.GenericService;
import com.fdb.basic.framework.core.vo.UserInfoCacheVO;
import com.fdb.efp.nls.service.dao.UserInfoCacheDao;
import com.fdb.efp.nls.service.facade.UserInfoCacheService;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 
 * 
 * 
 * @author Cytus_
 * @since 2018年6月14日 上午9:30:45
 * @version 1.0
 *
 */
@Service("userInfoCacheService")
public class UserInfoCacheServiceImpl implements UserInfoCacheService, GenericService {
    
    private static Logger logger = LoggerFactory.getLogger(UserInfoCacheServiceImpl.class);
    
    @Autowired
    private UserInfoCacheDao userInfoCacheDao;

    @Override
    public List<UserInfoCacheVO> queryAll() {
        List<UserInfoCacheVO> vos = null;
        try {
            logger.info("查询缓存用户信息开始......");
            vos = userInfoCacheDao.queryAll();
            logger.info("查询缓存用户信息结束, 查询数据条数:"+ vos.size());
        } catch (Exception e) {
            logger.error("查询缓存用户信息出现异常!", e);
        }
        return vos;
    }

	/**
	 * 实现 GenericService 重写invok方法
	 * 
	 * @param method
	 * @param parameterTypes
	 * @param args
	 * @return
	 * @throws GenericException
	 * @author zhangze
	 * @since 2019年3月30日 下午4:18:53
	 * @version 1.0
	 */
	@Override
	public Object $invoke(String method, String[] parameterTypes, Object[] args) throws GenericException {
		List<UserInfoCacheVO> resuList = null;
		if (StringUtils.isNotBlank(method) && method.equals("queryAll")) {
			resuList = queryAll();
		}
		return resuList;
	}

}
